home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / Jumpy&MulticolourText.pprx < prev    next >
Text File  |  1993-08-10  |  3KB  |  103 lines

  1. /* This Genie applies random colours and/or baseline shifts to a selected block of text. Warnings: it is slow, it increases the length of the selected text by a factor of 8 or 9 (because of all the style codes needed), and it slows ProPage down to a crawl. So only do it at the end when you have got everything else right. Note that any other style codes inside the block will be removed.
  2.  
  3. Written by Don Cox  ©  August 93. Not Public Domain. */
  4.  
  5. trace n
  6.  
  7. signal on error
  8. signal on syntax
  9. address command
  10.  
  11. if word(ppm_GetState(), 1) ~= 3 then exit_msg("You must be in edit mode to use this Genie")
  12.  
  13. text = ppm_GetBlockText(0)
  14. if text = '' then exit_msg("No text selected")
  15.  
  16. effect = ppm_Inform(3,"Select required effect","Jumpy","Both", "Multicoloured")
  17.  
  18. if effect = -1 then exit_msg("Something went wrong")
  19.  
  20. if effect<=1 then do
  21.     factor = ppm_GetUserText(8,"Maximum shift (points)")
  22.     if factor = "" then effect=2
  23.     if ~(datatype(factor,n)) then exit_msg("Invalid entry")
  24.  
  25.     if factor>600 then factor = 600
  26.     end
  27.  
  28. if effect >=1 then do
  29.     collist = ppm_GetColorList()
  30.     collist = substr(collist, pos('0a'x, collist) + 1) /* It begins with a number */
  31.     chosen = ppm_SelectFromList("Select colours",36,24,1,collist)
  32.     if chosen = "" then exit_msg("No colours chosen")
  33.  
  34.     n=1
  35.     do forever  /* put colours into a compound variable  */
  36.         parse var chosen acolour "0a"x chosen
  37.         if acolour = "" then break
  38.         colours.n = acolour
  39.         n=n+1
  40.         end
  41.     colournumber = n-1
  42.     end
  43.  
  44. call ppm_ShowStatus("  Processing text...")
  45.  
  46. /* Split into sections to avoid trouble with ARexx's limit of 64k on length of strings  */
  47. sections = (length(text)%2000)+1
  48. do i=1 to sections
  49.     texts.i.endofsection = 2000
  50.     if i = sections then texts.i.endofsection = length(text)//2000
  51.     texts.i.thisSection = substr(text, (2000*(i-1))+1, texts.i.endofsection)
  52.     end
  53.  
  54. do i = 1 to sections
  55.     position = 1
  56.     newtext = ""
  57.     do until position = texts.i.endofsection+1
  58.         if effect >= 1 then do
  59.             randcol = random(1,colournumber,time("s"))
  60.             thiscolour = colours.randcol
  61.             randbase = "\c<"||thiscolour||">"
  62.             end
  63.         if effect = 0 then randbase = "\ls<"||randu()*factor||">"
  64.         if effect = 1 then randbase = "\c<"||thiscolour||">\ls<"||randu()*factor||">"
  65.         nextchar = substr(texts.i.thisSection, position, 1)
  66.         newtext = newtext||randbase||nextchar
  67.         position = position+1
  68.         end
  69.     if i = 1 then call ppm_SaveText("PPage:textfile.temp",newtext)
  70.     if i>1 then call ppm_SaveMoreText("PPage:textfile.temp",newtext)
  71. end
  72.  
  73. call ppm_ShowStatus("  Removing old text...")
  74. success = ppm_Cut()
  75. if success ~= 1 then exit_msg("Cut failed")
  76. call ppm_ShowStatus("  Inserting new text...")
  77. success = ppm_InsertFile("PPage:textfile.temp")
  78. if success~=1 then exit_msg("Failed inserting altered text")
  79.  
  80. "delete PPage:textfile.temp"
  81. call exit_msg()
  82. end
  83.  
  84.  
  85.  
  86. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  87.  
  88. error:
  89. syntax:
  90.     do
  91.     exit_msg("Genie failed due to error: "errortext(rc))
  92.     end
  93.  
  94. exit_msg:
  95.     do
  96.     parse arg message
  97.     if message ~= "" then
  98.     call ppm_Inform(1,message,"Resume")
  99.     call ppm_ClearStatus()
  100.     exit
  101.     end
  102.  
  103.